package net.huashitong.ssydt.provider.msg.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.huashitong.ssydt.provider.msg.dto.SsApplicationMessage;
import net.huashitong.ssydt.provider.msg.dto.SsSingleMessage;
import net.huashitong.ssydt.provider.msg.service.MsgPushService;
import net.huashitong.ssydt.provider.web.model.Result;
import net.huashitong.ssydt.provider.web.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.11.16
 */
@Api(value = "/msg/push", tags = {"推送相关（后台）"})
@RestController
@RequestMapping("/msg/push")
public class MsgPushController {


    private MsgPushService msgPushService;

    @Autowired
    public MsgPushController(MsgPushService msgPushService) {
        this.msgPushService = msgPushService;
    }

    @ApiOperation(value = "推送个人消息", notes = "推送个人消息", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping("/single-message")
    public Result<String> pushSingleMessage(@RequestBody SsSingleMessage ssSingleMessage) {
        msgPushService.pushSingleMessage(ssSingleMessage);
        return ResultUtils.getSuccessResults();
    }


    @ApiOperation(value = "推送应用消息", notes = "推送应用消息", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping("/application-message")
    public Result<String> pushSingleMessage(@RequestBody SsApplicationMessage ssApplicationMessage) {
        msgPushService.pushMessageToApplication(ssApplicationMessage);
        return ResultUtils.getSuccessResults();
    }

}
